{template 'public/header'}{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_jypx/template/public/ygcss.css">
<style type="text/css">
    input[type="radio"] + label::before {
        content: "\a0"; /*不换行空格*/
        display: inline-block;
        vertical-align: middle;
        font-size: 16px;
        width: 1em;
        height: 1em;
        margin-right: .4em;
        border-radius: 50%;
        border: 2px solid #ddd;
        text-indent: .15em;
        line-height: 1; 
    }
    input[type="radio"]:checked + label::before {
        background-color: #44ABF7;
        background-clip: content-box;
        padding: .1em;
        border: 2px solid #44ABF7;
    }
    input[type="radio"] {
        position: absolute;
        clip: rect(0, 0, 0, 0);
    }
    #classes{
    	margin:20px 263px 0;
    	height: 50px;
    }
    #classes:after{
    	content: "";
    	height: 100%;
    	width: 20px;
    	background: #fff;
    	position: absolute;
	    top: 0;
	    right: 0;
    }
</style>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li><a href="{php echo $this->createWebUrl('teacher')}">老师管理</a></li>
    <li class="active"><a href="{php echo $this->createWebUrl('addteacher')}">添加老师</a></li>
</ul>
<div class="main">
    <form action="" method="post" class="form-horizontal form js_submit" enctype="multipart/form-data">
        <div class="panel panel-default ygdefault">
            <!-- <div class="panel-heading wyheader"> 添加老师</div> -->
            <div class="panel-body panel">
             <!-- {if empty($info)} -->
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="margin-right: 15px;">校区</label>
         
                    <select name="cate_name" id="school" style="float: left;">
                       <option value="0" disabled="disabled">请选择</option>
                     
                    </select>
                    <span style="margin-left:20px;width:30px;float:left;" class="control-label">学级</span>
                     <select name="course_name" id="coursecate"  style="float: left;margin-left: 20px;padding-right:45px;">
                        <option value="0" disabled="disabled">请选择</option>
                    </select>
                    <span style="margin-left:20px;width:30px;float:left;" class="control-label">课程</span>
                     <select name="name" id="course"  style="float: left;margin-left: 20px;padding-right:45px;">
                        <option value="0" disabled="disabled">请选择</option>
                    </select>
                    <div name="class_id" id="classes"  class="col-xs-8" style="height:auto !important;border: 1px solid #ccc;padding:8px;">
                        <script>
                               
                        </script>
                    </div>
                    <span class="help-block" style="color:#f00;clear: both;margin-left: 263px">点击勾选班级</span>
                    <div class="col-xs-12 col-sm-9 col-md-10 col-sm-push-3 col-md-push-2 ">
                    
                    </div>
                    
              </div>
                  <!-- {else}
                    <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="margin-right: 15px;">所在班级</label>
                     {loop $class $row}   
                        <td><div class="type-parent" name="class_name" value="{$row['id']}">{$row['class_name']}&nbsp;&nbsp;</div></td>            
                    {/loop}
                    </div>

         
                  {/if} -->
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">老师姓名</label>
                    <div class="col-sm-10 col-lg-9">
                        <input id="" name="teacher_name" type="text" class="form-control teacher_name" value="{$info['teacher_name']}"/>
                        <span class="help-block" id="submit">*请输入老师真实姓名</span>
                    </div>
                </div>
                 <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">登录账号</label>
                    <div class="col-sm-10 col-lg-9">
                        <input id="" name="username" type="text" class="form-control login" value="{$info['username']}"/>
                        <span class="help-block">*请输入用户名，用户名为3到12个字符组成，包括汉字，大小写字母</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">登录密码</label>
                    <div class="col-sm-10 col-lg-9">
                        <input id="password" name="password" type="password" class="form-control password" value="" autocomplete="off"/>
                        <span class="help-block">*请填写密码，密码为字母开头6-20位字母数字下划线</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">确认密码</label>
                    <div class="col-sm-10 col-lg-9">
                        <input id="repassword" name="repassword" type="password" class="form-control code" value="" autocomplete="off"/>
                        <span class="help-block">*重复输入密码，确认正确输入</span>
                    </div>
                </div>
                
              
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
                    <div class="col-sm-9">
                        <label class="radio-inline">
                            <input type="radio" class="state" id="qiyongc" name="state" value="1" {if $info['state']==1 || empty($info)}checked{/if}>
                            <label for="qiyongc">启用</label> 
                        </label>
                        <label class="radio-inline">
                            <input type="radio" id="qiyongc2" class="state" name="state" value="2" {if $info['state']==2}checked{/if}>
                            <label for="qiyongc2">禁用</label>
                        </label>
                    </div>
                </div>
               
            </div>
        </div>
        <div class="form-group">
            <input type="submit" name="submit" value="保存设置" class="btn col-lg-3" style="color: white;background-color: #44ABF7;" id="submit"/>
            
<!--           <button id="submit">保存设置</button>
 -->          <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>

    </form>
</div>
<!-- <script type="text/javascript">
    $(function(){
        // $("#frame-0").addClass("in");
        $("#frame-8").show();
        $("#yframe-8").addClass("wyactive");
    })
</script> -->
<script type="text/javascript">
             //表单提交
    //    $(".js_submit").submit(function(e){
    //     console.log("提交表单")
    //             var class_id =[];
    //             $("input:checkbox[name='class_id']:checked").each(function() { // 遍历name=test的多选框
				//   class_id.push($(this).val());  // 每一个被选中项的值
				//   // alert(class_id)
				// });
  		// 		alert(class_id)

    //             console.log(chk_value.slice(0,-1))
    //             var classes_id=chk_value.slice(0,-1)

    //             var teacher_name=$(".teacher_name").val()
    //             var username=$(".login").val()
    //             var password=$(".password").val()
    //             // var val=$('input:checkbox:checked').val()
    //             var state=$('input:radio:checked').val()
    //             console.log(state)
    //             // console.log(val)

    //            $.ajax({
    //               type:"post",
    //               url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Teacher&m=zh_jypx",
    //               dataType:"json",
    //               data:{
    //                 username:username,
    //                 teacher_name:teacher_name,
    //                 password:password,
    //                 class_id:class_id,
    //                 state:state
    //               },
    //               success:function(res){  

    //               console.log(res)

    //               }
    //           })
    //    })

     $.ajax({
                  type:"post",
                  url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=school&m=zh_jypx",
                  dataType:"json",
                  data:{},
                  success:function(res){  
                        console.log(res.list)
                        var all=res.list
                        for(var i=0;i<all.length;i++){
                           console.log(all[i].id)
                           $("#school").append("<option value='"+all[i].id+"'>"+all[i].cate_name+"</option>");
                        }
                        // $("#school").append("<option value='"+id+"'>"+thid+"</option>").attr("selected", true);

                  }
              })
     function one(value){
            console.log("执行一")

     		  $.ajax({
                  type:"post",
                  url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=CourseCate&m=zh_jypx",
                  dataType:"json",
                  data:{school_id:value},
                  success:function(res){  

                        console.log(res)
                        var grade=res.list
                        console.log(grade)
                        if(res.code==500){
                          $("#coursecate").css("display","none")
                          $("#course").css("display","none")
                          $("#classes").css("display","none")
                       }else{
                       for(var i=0;i<grade.length;i++){
                          
                           $("#coursecate").append("<option value='"+grade[i].id+"'>"+grade[i].course_name+"</option>");
                        }
                        console.log("年级id:"+grade[0].id)
                        two(grade[0].id)
                       }

                  }
              })
     }
     function two(value){
      console.log("执行二")
     	 $.ajax({
                  type:"post",
                  url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Course&m=zh_jypx",
                  dataType:"json",
                  data:{c_id:value},
                  success:function(res){  

                        console.log(res)
                        var course=res.list
                        console.log(course)

                        for(var i=0;i<course.length;i++){
                           console.log(course[i].id)
                           $("#course").append("<option value='"+course[i].id+"'>"+course[i].name+"</option>");
                        }
                        console.log("课程id:"+course[0].id)
                        three(course[0].id)


                  }
              })
     }
     function three(value){
console.log('没有执行')
 $.ajax({
            type:"post",
            url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Class&m=zh_jypx",
            dataType:"json",
            data:{cou_id:value},
            success:function(res){  

                  // console.log(res)
                  var classes=res
                  console.log(classes)

                  for(var i=0;i<classes.length;i++){
                     console.log(classes[i].id)
                     // $("#classes").append("<option value='"+classes[i].id+"'>"+classes[i].class_name+"</option>");
                      $("#classes").append("<div><input class='check' type='checkbox' name='class_id[]' value='"+classes[i].id+"'>"+classes[i].class_name+"</input></div>");
                     
                  }
            }
        })
}
    $("#school").change(function(){
        var school_id=$("#school option:selected").val()
        $("#coursecate").html("")
         $("#course").html("")
        $("#classes").html("")
        // console.log(list)
        if(school_id!=0){
          console.log("获取学校id"+school_id)
          one(school_id)        
        }

    })

    $("#coursecate").change(function(){
        var c_id=$("#coursecate option:selected").val()
        $("#course").html("")
        $("#classes").html("")
        // console.log(list)
        console.log("获取年级id"+c_id)
        two(c_id)

    })

       $("#course").change(function(){
        var cou_id=$("#course option:selected").val()
        var list=$("#classes").html("")
        console.log(list)
        // console.log(list)
        console.log("获取课程id"+cou_id)
        three(cou_id)
    })

//获取选中复选框的值-->
            // $("#submit").click(function(){
            //   // var num=$("input[checked]").val()
            //   // console.log(num)
            //     var chk_value =[];
            //     $("input[checked]").each(function(i){
            //         chk_value.push($(this).val());
            //         //console.log(chk_value)
            //     });
            //     console.log(chk_value.slice(0,-1))

            // });

    $(function(){
        $("#frame-6").show();
        $("#yframe-6").addClass("wyactive");
        $(".searchname").hide();
        // $(".ygbtn").on("click",function(){

        //     var ygsinput = $("#ygsinput").val();
        //     console.log(ygsinput)
        //     if(ygsinput.length==''){
        //       $(".searchname").html('');
        //     }else{
        //       $(".searchname").html('')  
        //       var keywords = $("#ygsinput").val()
        //       $.ajax({
        //           type:"post",
        //           url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=School&m=zh_jypx",
        //           dataType:"text",
        //           data:{keywords:keywords},
        //           success:function(data){                    
        //               var data = eval('(' + data + ')')
        //               console.log(data);
        //               $(".searchname").show();
        //               for(var i=0;i<data.length;i++){
        //                 $(".searchname").append('<div class="shnbox" data-dismiss="modal" id="'+data[i].id+'"><a href="javascript:void(0);"><p>'+data[i].name+'</p></a></div>')
        //               }
        //               $(".shnbox").each(function(){
        //                 $(this).click(function(){
        //                     // 获取选中的用户id
        //                     var thid = $(this).text()
        //                     // 获取选中的用户name
        //                     var user_id = $(this).attr("id")
        //                     // 根据选中的用户新增一个option
        //                     $("#username").append("<option value='"+user_id+"'>"+thid+"</option>").attr("selected", true);
        //                     // 点击之后让value等于user_id的options显示
        //                     $("#username").val(user_id);
        //                 })
                        
        //               })
                      
        //           }
        //       }) 
        //     }
            
        // })
    })
</script>